package com.vito.dcs.water.trace.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSONObject;
import com.vito.base.model.DataGrid;
import com.vito.base.model.ResMsg;
import com.vito.base.model.Result;
import com.vito.dcs.intface.dao.IntfaceMapper;
import com.vito.dcs.water.trace.dao.TraceWaterMapper;
import com.vito.dcs.water.trace.model.TraceWaterModel;
import com.vito.dcs.water.trace.service.TraceWaterService;

/**
 * TraceWaterService接口实现类
 * @author  lyhao E-mail: 
 * @version 0.0.1
 * @date    2019-4-23 16:07:24
 */
@Service
public class TraceWaterServiceImpl implements TraceWaterService {
	
	@Autowired
	private TraceWaterMapper tracewaterMapper;
	
	@Override
	public void saveTraceWater(TraceWaterModel tracewater){
		        
		tracewaterMapper.saveTraceWater(tracewater);
	}
	@Override
	public DataGrid<TraceWaterModel> queryTraceWaterByPage(TraceWaterModel tracewater){
		DataGrid<TraceWaterModel> dg = new DataGrid<TraceWaterModel>();
		dg.setRows(tracewaterMapper.queryTraceWaterByPage(tracewater));
		dg.setTotal(tracewater.getTotal());
		return dg;
	}
	@Override
	public TraceWaterModel queryTraceWater(TraceWaterModel tracewater){
		return tracewaterMapper.queryTraceWater(tracewater);
	}
	@Override
	public TraceWaterModel updateTraceWater(TraceWaterModel tracewater){
		tracewaterMapper.updateTraceWater(tracewater);
		return null;
	}
	
	@Override
	public Integer deleteTraceWater(TraceWaterModel tracewater){
		return tracewaterMapper.deleteTraceWater(tracewater);
	}
	
	@Autowired
	private IntfaceMapper intfaceMapper;
	
	@Override
	public Result findQualityInfo(String id) {
		Result rs = new Result();
		Map<String,String> map = new HashMap<String,String>();
		try{
			JSONObject json = new JSONObject();
			TraceWaterModel tracewater = new TraceWaterModel();
			tracewater.setId(id);
			tracewater = tracewaterMapper.queryTraceWater(tracewater);
			json.put("traceAsphalt", tracewater);
			map.put("sectionId", tracewater.getSectionId());
			List<HashMap<String,String>> consList = intfaceMapper.querySysConstructionVehicleByAreaId(map);
			json.put("consList", consList);
			rs.setCode(Result.CODE_OK);
			rs.setData(json);
		}catch(Exception ex){
			rs.setCode(Result.CODE_ERROR);
			rs.setMsg(ResMsg.EXECERR);
		}
		return rs;
	}

}